<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui-date,layer,layui'}){}%>
</head>

<body>

<div class="wrapper wrapper-content">
	<div class="row">
		<div class="col-sm-12">
			<!-- START 数据表格 -->
			<table id="dealTable"
				   data-toolbar="#toolbar"
				   data-side-pagination="server"
				   data-pagination="true"
				   data-resizable="true"
				   data-side-pagination="server"
				   data-url="/sea/pdf/findByCnd.do?createPlanNo=${createPlanNo}"
				   data-page-size="15">
			</table>
			<!-- END 数据表格 -->

			<!-- END 右侧数据 -->
		</div>
	</div>
</div>
<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,bootstrap-table-zh-CN,layer,laydate'}){}%>
<script>
    var $dealTable = $('#dealTable'),selections=[];

	laydate.render({
		elem: '#recordOperateDate',
		type: 'date',
		trigger: 'click', //修改触发方式
		format: 'yyyy-MM-dd'
	});
    $(function(){

        //START 表格配置
        $dealTable.bootstrapTable({
            height: getHeight(),
            columns: [
                {
                    title: '柜号',
                    field: 'pdfPlanNo',
                    align: 'left',
                    valign: 'middle'
                },
				{
					title: '供应商',
					field: 'pdfSupplierName',
					align: 'left',
					valign: 'middle'
				},
                {
                    title: '下载附件',
                    field: 'pdfFile',
                    align: 'left',
                    valign: 'middle',
					formatter:function (v,r) {
						if(null!=v && v!=''){
							var result='<button  class="download-btn layui-btn  layui-btn-sm"  style="margin-top: -6px;margin-left: -4px">';
							result+='<i class="fa fa-download" aria-hidden="true"></i> <a href="'+v+'" download style="color: white">下载附件</a>';
							result+='</button>';
							return result;
						}else{
							return '';
						}
					}
                },
				{
					title: '操作',
					field: 'operate',
					align: 'center',
					valign: 'middle',
					formatter: optFormatter
				}
            ],
            onLoadSuccess : function() {
				$('.edit-btn').on('click',function(){
					var id = $(this).attr('data-val');
					$('#id').val(id);
					$("#recordOperateDate").val($(this).attr("data-val-name"));
					layer.open({
						type:1,
						title:'确认日期',
						area:['600px','250px'],
						skin:'layui-layer-lan',//layui-layer-molv ;layui-layer-lan;layui-layer-rim;layer-window
						shadeClose:false,
						resize: false,
						scrollbar: false,
						maxmin: false,//出现最大化按钮
						content:$('#layer_window')
					})
				});
            }
        });
        //END 表格配置

        //表格高度自适应
        $(window).resize(function () {
            $dealTable.bootstrapTable('resetView', {
                height: getHeight()
            });
        });
    });


    //表格高度计算
    function getHeight() {
        return $(window).height() - $('.btn-group').outerHeight(true) - $('.breadcrumb').outerHeight(true)-60;
    }

	function optFormatter(value,row){
		var content = '';
		if(row.recordOperateDate!=null && row.recordOperateDate!='')
		{
			content += '<button class="edit-btn btn btn-xs btn-info" data-val-name="' + row.recordOperateDate + '" data-val="' + row.id + '" title="修改"><i class="fa fa-edit"></i>  </button>';
		}
		return content;
	}


	//提交表单
	$('.save-btn').on('click',function(){
		var id=$("#id").val();
		//清关计划
		layer.confirm('确定要修改当前日期？', {
			btn: ['确定','取消'],title:'提示'
		}, function(){
			var id=$("#id").val();
			var recordOperateDate=$("#recordOperateDate").val();
			if(recordOperateDate==''){
				parent.layer.msg('请选择日期！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
				return;
			}
			layer.closeAll();
			var index=layer.load();
			$.post('/bbpk/physical/record/usave.do',{id:id,recordOperateDate:recordOperateDate},function(data){
				if( data.ok ){
					$dealTable.bootstrapTable('refresh');
					layer.msg(data.msg,{icon:1,time:1500,shade: [0.8, '#393D49']});
					layer.close(index);
				}else{
					layer.msg(data.msg,{icon: 0,time:5000,shade: [0.8, '#393D49']});
					layer.close(index);
				}
			});
		});
	});

</script>
</body>
</html>
